package com.heima.wemedia.listen;

import com.heima.model.common.constants.admin.NewsAutoScanConstants;
import com.heima.wemedia.service.WmNewsAutoScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j

public class WemediaNewsAutoListener {
    @Autowired
    private WmNewsAutoScanService wmNewsAutoScanService;

    /**
     * queues   监听指定队列，但是不会自动创建队列
     * queuesToDeclare      监听指定队列，如果不存在队列会自动创建队列
     *bindings      监听指定队列，如果不存在队列会自动创建，还会自动创建对应的交换机和路由key
     * @param id
     */
    @RabbitListener(queuesToDeclare = @Queue(NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_QUEUE))
    public void handleAutoListener(String id){
        log.info("接收到自动审核队列消息 监听队列：{}   消息id：{}",NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_QUEUE,id);
        wmNewsAutoScanService.autoScanWmNews(Integer.valueOf(id));
    }
}
